public class ActivityNode {

	private String id;
	private List<String> authors;
	private String content;
	private List<String> contributors;
	private AtomDateTime published;
	private List<String> tags;
	private String title;
	private AtomDateTime updated;
	private String link;
	private Integer weight;
	private List<String> common = new List<String>();
	private String activityLink;
	
	public ActivityNode() {
	} 
	
	public ActivityNode(String id, 
						List<String> authors, 
						String content, 
						List<String> contributors,
						DateTime published, 
						List<String> tags, 
						String title, 
						Datetime updated, 
						String link, 
						String activityLink) {
		this.id = id;
		this.authors = new List<String>();
		this.contributors = new List<String>();
		this.tags = new List<String>();
		this.common = new List<String>();
		
		setAuthors(authors);
		setContent(content); 
		setContributors(contributors);
		setPublished(new AtomDateTime(published));
		setTags(tags);
		setTitle(title);
		setUpdated(new AtomDateTime(updated));
		setLink(link);
		setWeight(1);
		setActivityLink(activityLink);
	}
	
	
	public void setid(String id){
		this.id = id;
	}
	
	public void setAuthors(List<String> authors){
		this.authors.clear();
		this.authors.addAll(authors);
	}
	
	public void setContent(String content){
		this.content = content;
	}
	
	public void setContributors(List<String> contributors){
		this.contributors.clear();
		this.contributors.addAll(contributors);
	}
	public void setLink(String link){
		this.link = link;
	}

	public void setPublished(AtomDateTime published){
		this.published = published;
	}
	public void setPublished(DateTime published) {
		this.published = new AtomDateTime(published);
	}
	
	public void setTags(List<String> tags){
		this.tags.clear();
		this.tags.addAll(tags);
	}
	
	public void setActivityLink(String activityLink) {
		this.activityLink = activityLink;
	}
	
	public void setTitle(String title){
		this.title = title;
	}
	public void setUpdated(AtomDateTime updated){
		this.updated = updated;
	}
	public void setUpdated(DateTime updated) {
		this.updated = new AtomDateTime(updated);
	}
	
	public void setWeight(Integer weight){
		this.weight = weight;
	}
	public void setCommon(List<String> common){
		this.common.clear();
		this.common.addAll(common);
	}
	
	public String getid(){
		return id;
	}
	
	public List<String> getAuthorNames(){
		return authors;
	}
	
	public String getAuthor() {
		return authors.get(0);
	}
	
	public String getContent(){
		return content;
	}
	
	public List<String> getContributors(){
		return contributors;
	}
	
	public String getLink(){
		return link;
	}
	
	/**
	 *  Returns the fully qualified link to the activity
	 */
	public String getActivityLink() {
		return activityLink;
	}
	
	/**
	 *  Returns the path portion of the activity link
	 */
	public String getActivityPath() {
		String path = activityLink.replace(AtomService.staticStart, '');
		if (path.indexOf('&') != -1) {
			path = path.subString(0, path.indexOf('&'));
		}
		return path;
	}

	public AtomDateTime getPublished(){
		return published;
	}
	
	public List<String> getTags(){
		return tags;
	}
	
	public String getTitle(){
		return title;
	}
	
	public AtomDateTime getUpdated(){
		return updated;
	}
	public Integer getWeight(){
		return weight;
	}
	public List<String> getCommonList(){
		return common;
	}
	public Integer incWeight(){
		return ++weight;
	}
	public void addToCommonList(String commonNode){
		common.add(commonNode);
	}

	public String tosString(){
		return 'ID: '+id+'\nTitle: '+title+'\nURL: '+link;
	}


	public Integer compare(ActivityNode node1, ActivityNode node2) {
		if (node1 == null || node2==null){
			return 0;
		}
		return (node1.getWeight() - node2.getWeight());
	}


	public boolean equals(ActivityNode node) {
		ActivityNode connectionsNode = null;
		connectionsNode = (ActivityNode)node;
		if(connectionsNode == null){
			return false;
		}
		return ( this.getid().equals(connectionsNode.getid()) && this.getTitle().equals(connectionsNode.getTitle()) );
	}


	public Integer compareTo(ActivityNode node) {
		if(node == null){
			return 0;
		}
		return (this.getWeight() - node.getWeight());
	}

}